﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class Hero
{
	// csv fields
	public int ID;
	public string Name;
	public int Power;
	public List<int> SkillIDs;

	// real-time fields
	public bool Active;
	public List<Skill> Skills;
	public uint Level;
	public uint SkillLevel;

	public Hero(){}

	public void Initialize(SkillsConfig skillsConfig)
	{
		Skills = new List<Skill>(SkillIDs.Count);
		for (int i = 0; i < SkillIDs.Count; i++)
		{
			int index = SkillIDs[i];
			Skills.Add(skillsConfig.Skills[index-1]);
		}
	}

	public int AttackPower()
	{
		int power = Power;

		// level additive
		for (uint i = 0; i < Level; i++)
		{
			power = (int)(power*1.3f);
		}

		// skill additive
		for (int i = 0; i < SkillLevel; i++)
		{
			power = (int)(power*Skills[i].HeroScale());
		}
		return power;
	}

	public float GlobalScale()
	{
		float globalScale = 1;
		foreach(Skill item in Skills){
			globalScale *= item.GlobalScale();
		}
		return globalScale;
	}
}
